---
title: safeInteger
description: Creates a safe integer validation action.
source: /actions/safeInteger/safeInteger.ts
contributors:
  - fabian-hiller
---

import { ApiList, Property } from '~/components';
import { properties } from './properties';

# safeInteger

Creates a safe integer validation action.

```ts
const Action = v.safeInteger<TInput, TMessage>(message);
```

## Generics

- `TInput` <Property {...properties.TInput} />
- `TMessage` <Property {...properties.TMessage} />

## Parameters

- `message` <Property {...properties.message} />

### Explanation

With `safeInteger` you can validate the value of a number. If the input is not a safe integer, you can use `message` to customize the error message.

## Returns

- `Action` <Property {...properties.Action} />

## Examples

The following examples show how `safeInteger` can be used.

### Safe integer schema

Schema to validate an safe integer.

```ts
const SafeIntegerSchema = v.pipe(
  v.number(),
  v.safeInteger('The number must be a safe integer.')
);
```

## Related

The following APIs can be combined with `safeInteger`.

### Schemas

<ApiList items={['any', 'custom', 'number', 'unknown']} />

### Methods

<ApiList items={['pipe']} />

### Utils

<ApiList items={['isOfKind', 'isOfType']} />
